   prompt_edges:       db  'Calculating edges ..',0
   prompt_norm         db  'Calculating normals ..',0
   prompt_displ        db  'Making displacement ..',0
   prompt_tri          db  'Do triangulation ..',0
   prompt_unused_vert  db  'Remove unused vertices ..',0
   prompt_red_vert     db  'Remove redundant vertices ..',0
   prompt_inside_fac   db  'Remove inside faces ..',0
   prompt_rm_cracks    db  'Remove cracks ..',0
   prompt_det_chunks1  db  'Chunks detecting - first stage ..',0
   prompt_det_chunks   db  'Chunks detecting - second stage ..',0
   prompt_det_coll_ed  db  'Collided edges detecting ..',0
   prompt_smooth_in_ed db  'Smooth inside edges..',0
 ;  prompt_ray_sh       db  'Calculating ray casted shadows ..',0
 ;  prompt_ray_shd      db  'Ray casted shadows',0
   prompt_tes_tiv      db  'Teslating triangles with inner vertices ..',0
   prompt_mark_inn_vr  db  'Mark inside vertices ..',0
   prompt_opt          db  'Optimize chunks..',0

   uniq_ed             db  'Unique edges:',0
   faces               db  'Faces:',0
   vertices            db  'Vertices:',0
   edges_inter         db  'Collided edges:',0
   chunks_info         db  'Separate chunks number:',0
   in_vert_info        db  'Inside vertices number:',0
   curr_edit_pr_info   db  'Current edition particle:',0
 ;  double_edges_info   db  'Double edges count:',0
   sh_model:
        .shd   TCHAR     'Spot light',0
        .fl    TCHAR     'Flat Shading',0
        .gr    TCHAR     'Gouraud Shading',0
        .sp    TCHAR     'Spherical Environment Mapping',0
        .bm    TCHAR     'Bump Mapping',0
        .tx    TCHAR     'Texture Maping',0
        .grtx  TCHAR     'Gouraud Shading and Texture Mapping',0
        .dtxx  TCHAR     'Double Texture Mapping',0
        .bmtx  TCHAR     'Bump and Texture Mapping Pararell',0
        .grl   TCHAR     'Gouraud Shaded Line',0
        .flf   TCHAR     'Flat Shading',0
        .txl   TCHAR     'Textured Line - Env. Mapping',0
        .tx12  TCHAR     'Textured Line',0
        .line  TCHAR     'Simple line without z coord. interp.',0
        .shad  TCHAR     'Nodes of object',0
        .ph    TCHAR     'Real Phongs Shading',0
        .btp   TCHAR     'Tex. with bilinear filtering + Phong',0
        .gls   TCHAR     'Glass like rendering',0
        .gls_t TCHAR     'Glass + texture mapping rendering',0
        .wtr   TCHAR     'Weighted transparency',0
        .dp    TCHAR     'Depth peeling transparency',0
        .fr    TCHAR     'Fur rendering',0
    ;    .rc    TCHAR     'Ray casted shadows',0
if 0
  events:
   dd    WM_KEYDOWN
   dd    WM_PAINT
   dd    WM_SIZE
   dd    WM_LBUTTONDOWN
   dd    WM_MOUSEMOVE
   dd    WM_LBUTTONUP
   dd    WM_RBUTTONDOWN
   dd    WM_RBUTTONUP
   dd    WM_DESTROY

 events_labels:
   dw      WindowProc.wmkeydown     - WindowProc
   dw      WindowProc.wmpaint       - WindowProc
   dw      WindowProc.wmsize        - WindowProc
   dw      WindowProc.wmlbuttondown - WindowProc
   dw      WindowProc.wmmousemove   - WindowProc
   dw      WindowProc.wmlbuttonup   - WindowProc
   dw      WindowProc.wmrbuttondown - WindowProc
   dw      WindowProc.wmrbuttonup   - WindowProc
   dw      WindowProc.wmdestroy     - WindowProc
   dw      WindowProc.defwindow     - WindowProc
end if


shd_model_addr:
  dw  sh_model.shd   -  sh_model
  dw  sh_model.fl    -  sh_model
  dw  sh_model.gr    -  sh_model
  dw  sh_model.sp    -  sh_model
  dw  sh_model.bm    -  sh_model
  dw  sh_model.tx    -  sh_model
  dw  sh_model.grtx  -  sh_model
  dw  sh_model.dtxx  -  sh_model
  dw  sh_model.bmtx  -  sh_model
  dw  sh_model.grl   -  sh_model
  dw  sh_model.flf   -  sh_model
  dw  sh_model.txl   -  sh_model
  dw  sh_model.tx12  -  sh_model
  dw  sh_model.line  -  sh_model
  dw  sh_model.shad  -  sh_model
  dw  sh_model.ph    -  sh_model
  dw  sh_model.btp   -  sh_model
  dw  sh_model.gls   -  sh_model
  dw  sh_model.gls_t -  sh_model
  dw  sh_model.wtr   -  sh_model
  dw  sh_model.dp    -  sh_model
  dw  sh_model.fr    -  sh_model
; dw  sh_model.rc    -  sh_model
    inner_vert_ptr       dd 0
    chunks_ptr           dd 0   ; list of words corresponding to triangles_ptr list
                                ; every word = No. of chunk apropriate tri
                                ; is member
    edges_intersect_ptr  dd 0
    curr_chunk           dd -1
    edges_d_count        dd 0   ; edge double/single
    ccounter             dd 0
    isAVX                db 0   ; CPU features
    isSSE42              db 0

    chunks_count         dd 0
;   crytic_flag          dw 0
    XYZpartices:
    db 'X','Y','Z'
    peeling_particle dd  0.1
    tex_x_div2f:     dd  0.5
    tex_y_div2f      dd  0.5
    tex_x_div2:      dd  TEX_X / 2
    tex_y_div2       dd  TEX_Y / 2
    i9               dd  9
    i1000            dd  1000
    irecipr3         dd  0x55555555
    env_const        dd  1.05
    two_pi           dd  6.2831853
    pi               dd  3.1415


    displac_div      dd  5800   ;* 3 ; displacement divisior
    rand_seed        dd  0x128e ;f2a6daf2   0x1f1f1f1f

    Bfile_name     db 'object '
    .en            db '.3ds',0
    stl_file_name  db 'object '
    .en:           db '.stl',0
    ply_file_name  db 'object '
    .en:           db '.ply',0
    asc_file_name  db 'object '   ;  ,_,_,_,_,_,_
    .en:           db '.asc',0
    Chfile_name    db 'chunks '   ;  ,_,_,_,_,_,_
    .en:           db '.bin',0                                   
    wav_file_name  db 'soundd '
                   db '.wav',0
    mod_file_name  db 'soundd '
                   db '.mod',0
;bin_img_file_name  db 'im2_bi '
;                   db '.bin',0
  ;  bez_file_name  db 'bez_nd '
  ;                 db '.bin',0             
  ;  jpg_file_name  db 'scr_so '
  ;                 db '.jpg',0
     img_txt:
   ;  file 'compressed_image'
     img_txt_size =  $ - img_txt 
     
     
    save_procs:
     dd     save3ds
     dd     write_stl
     dd     write_ply
     dd     write_asc
     dd     save_chunks_file
     dd     save_wav
     dd     save_mod
   ;  dd     img_txt_bin  ;   save_bezier ; save_bezier_rects ;
   ;  dd     SaveJpgFile
    object_cnt     db 'A'
    plane_equation:
     .A dd 0.5
     .B dd 0.5
     .C dd 1.0
     .D dd 0.0
    scale          dd 200.0
    scale_plus     dd 1.2         ;
    scale_minus    dd 0.8         ;
    tex_scale      dd 255.0       ;
    bbuffer_ptr    dd Bbufferv
    inf_screen_ptr dd Info_screen
    next_varw:
    next_var       dd INFOY + MYRES ; - FONT_FIX

;---------not change order below
    NextMsub:        dw BXRES/2
                     dw BXRES/2
                     dw BXRES/2
                     dw 0
; dq (BYRES/2) shl 32+ (BYRES/2) shl 16 + BXRES/2
    NextScaleZero    dw BYRES/2
    NextRotatZero:   dw BYRES - 10 ,   20
    NextScaleXYZero: dw BYRES/2 + 12, BYRES/2
    NextBendZero:    dw 12   , BYRES/2
                     dw BYRES/2  - 12 , BYRES/2
                     dw BYRES/2  + 24 , BYRES/2
                     dw BYRES    - 24 , BYRES/2
;---------not change order above

    minWinX            dd BXRES + 40      ;  \
    minWinY            dd BYRES + 40      ;  /  dont change order
    NextCurvConst:     dd NEXT_CURV_NUMB/2 ,  NEXT_CURV_NUMB/2
    NextMotion         dw 0
    NextPointsCount    dd 0
    NextTrianglesCount dd 0
    tex_button_pres    db 0  ; various marks
    do_submit          db 0
    greatest_chunk     dd 0
    piD128:
    one_deg            dd 0.024543692
    main_rotary:       dd 0, 0, 0
    all_lights_size    dw lightsend-lights
  align 16
    xxaddi:
    xxadd:             dd   ?  ;XRES/2
    yyaddi:
    yyadd              dd   ?  ;YRES/2
    zaddi:
    zzadd              dd 0
                       dd 0
    tri_area_x1:       dd 7.0        ; \       ; tesselate area
    tri_area_y1        dd 7.0        ; |>
    tri_area_x2:       dd 2000.0     ; |>  dont change order
    tri_area_y2        dd 2000.0     ; /
    point_light_coords:
              dd 50.0
              dd 50.0
              dd 215.0
              dd 0.0

              dd 815.0
              dd 815.0
              dd 215.0
              dd 0.0

              dd 1500.0
              dd 1500.0
              dd -215.0
              dd 0.0

  lights_aligned:
  ;  .light_vect
                 dd   0.1, 0.1, -1.0, 0.0
  ;  .light_c_o:                     ;   +16
                 dd   50.0, 49.0, 44.0, 0.0
  ;  .light_c_min:                   ;   +32
                 dd   30.0, 41.0, 30.0, 0.0
  ;  .light_c_max:                   ;   +48
                 dd   235.0, 235.0, 5.0, 1.0

       dd   -0.5,-0.5,-1.0, 0.0
       dd   32.0, 27.0, 17.0, 0.0
       dd   1.0,1.0,1.0,0.0
       dd   253.0,253.0,235.0,0.0

       dd   0.5,0.5,-1.0,0.0
       dd   13.0,1.0,1.0,0.0
       dd   7.0,3.0,7.0,0.0
       dd   25.0, 255.0, 253.0, 0.0
  lights_aligned_end:

     aprox:          dd 1.1, 1.1, 1.1, 1.1
     slices_factor1: dd 1.1, 1.1, 1.1, 1.1
     slices_factor2: dd 0.65, 0.65, 0.65, 0.65
     slices_factor3: dd 0.45, 0.45, 0.45, 0.45
     slices_factor4: dd 0.3, 0.3, 0.3, 0.3
     slices_factor5: dd 0.23, 0.23, 0.23, 0.23
     slices_factor6: dd 0.2, 0.2, 0.2, 0.2
     slices_factor7: dd 0.1, 0.1, 0.1, 0.1

    ffd_scale:       dd 4 dup 0.9     ;  \   dont change
    ffd_center:      dd 4 dup 0       ;  /   order

    blur_sub:
    sli_cnt_const:
       dd 0x01010101, 0x01010101, 0x01010101, 0x01010101
    muler1234:
    const1234:
       dd 1.0
       dd 2.0
       dd 3.0
       dd 4.0
    muler0_7:
    muler0123:
       dd 0.0
       dd 1.0
       dd 2.0
       dd 3.0
       dd 4.0
       dd 5.0
       dd 6.0
       dd 7.0
align 16
one_hgst_dd:
           dd 0.0, 0.0, 0.0, 1.0

sign_mask:                       ;  \
           dd 4 dup 0x80000000   ;  |
zero_hgst_dd:                    ;  |
zero_hgst:                       ;  | > dont change order
           dd -1,-1,-1,0         ;  |
f05x3:     dd 3 dup 0.5          ;  |
           dd 0.0                ;  /
z_abs_mask:
           dd 2 dup 0xffffffff
           dd 0x7fffffff
           dd 0xffffffff
abs_mask:
           dd 4 dup 0x7fffffff
f490x3:    dd 490.0, 490.0, 490.0, 0.0
f500x3:    dd 500.0, 500.0, 500.0, 0.0

z_minus_mask:
              dd 0,0,0x80000000,0
f255d:
mask_255f:
correct_texf:
              dd 4 dup 255.0
f3:
const3:
              dd 4 dup 3.0
const4:
              dd  4.0, 4.0, 4.0, 4.0
margin3fur:
              dd -5,-5,5,5 ; 3fur.inc  ...
constrecip3:  dd  4 dup 0.333333
if 0
aabb:     ; axis aligned bounding box vars
  .cn1:     dd 1.0,1.0,1.0,0  ; corner1 of box
  .cn2:     dd -1.0,1.0,1.0,0
  .cn3:     dd 1.0,-1.0,1.0,0
  .cn4:     dd -1.0,-1.0,1.0,0
  .cn5:     dd 1.0,1.0,-1.0,0
  .cn6:     dd -1.0,1.0,-1.0,0
  .cn7:     dd 1.0,-1.0,-1.0,0
  .cn8:     dd -1.0,-1.0,-1.0,0
end if
  tex_m2:                                        ; \
    dd 4 dup 510.0                               ; |
  f2x4:                                          ; |
    dd 2.0, 2.0, 2.0, 2.0                        ; |> dont xchg
  the_one:                                       ; |  order
  const1:                                        ; |  (real bump)
    dd 4 dup 1.0                                 ; |  (3glass_tex.inc file)
  bump_consts2:   dd  -TEX_Y,-1,TEX_Y-1,TEX_Y*2  ; |
  bump_trunc:     dd  4 dup  TEXTURE_SIZE        ; |
  b_shf1:         db  4, 5, 8, 9, 0, 1, 5, 6     ; |
  b_shf2:         db  6, 7, 10, 11, 9, 10, 2, 3  ; |
  norm_dev:       dd  4 dup 0.0043               ; |
  norm_dev2:      dd  2 dup 0.0043               ; /
  shuf_bifil:     db  0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14  ;  bi_filter_avx2
align 16
margin:     dd 3 dup 0.03
            dd 0
eps1:       dd 4 dup 0.000001
eps2:       dd 4 dup 0.000002

eps_inter:              ;  \
            dd 0.0001   ;  |  dont change order
epsminus:   dd -0.0001  ;  |
epsone      dd 1.0001   ;  |
one         dd 1.0      ;  /
eps3        dd 0.0001

ply_header:
include 'ply.inc'
;trids_header:
;file    '3ds.3ds'
;TRIDS_HEADER_LEN = $ - trids_header
long_pipe_segs_c      dd 4
long_pipe_one_seg_c   dd 12  ;12 ; must be divisable by 4

  lights:
    light_vect      dd   0.0,0.0,-1.0
    light_c_o:                       ; +12
    p_light_o:
                    dw   51,71,11,0
    light_c_min:                     ; +20
    p_light_min:
                    dw   15,99,17,0
    light_c_max:
    p_light_max:
                    dw   235,255,5,0 ; +28
    shiness:
                    dw   5           ; +36
    LIGHT_SIZE = ($-lights)
        dd   -0.3,0.3,-1.0         ;   +12
        dw   1,255,1,0             ;   +20
        dw   1,1,1,0               ;   +28
        dw   200,255,255,0
        dw   5                     ;   +36

        dd   0.3,-0.3,-1.0
        dw   13,1,1,0
        dw   70,30,70,0
        dw   25,255,255,0
        dw   5
   lightsend:

filter     TCHAR   '3d Studio objects (*.3ds)',0,'*.3ds',0,\
                   '3d Studio objects (*.asc)',0,'*.asc',0,\
                   'Stanford binary objects (*.ply)',0,'*.ply',0,\
                   'md2 objects (*.md2)',0,'*.md2',0,\
                   'lwo objects (*.lwo)',0,'*.lwo',0,\
                   'All files (*.*)',0,'*.*',0,0
;_not3ds    TCHAR   'Not an 3d object file or read error.',0
;_notraw    TCHAR   'Not an RAW 512X512 file or read error.',0
_ferr      TCHAR   'File read error. ',0
filter_tex TCHAR   'bmp file (*.bmp)',0,'*.bmp',0,\
                   'raw file 512X512 (*.raw)',0,'*.raw',0,\
                   'All files (*.*)',0,'*.*',0,0

; Sanctssimi Cordis Christi section |+++++++++++++++++++++++++++++
      hrt_points:
      ;cordis
      db 63,87,10, 87,87,10, 106,106,10, 125,87,10, 150,87,10, 162,100,10, 160,125,10
      db 150,150,10, 106,175,10, 62,150,10, 50,125,10, 50,100,10,87,125,0,125,125,0
      ;crux
      db 87,67,11,  100,67,11, 100,56,11,  112,56,11,   112,67,11, 125,67,11
      db 125,75,11, 112,75,11, 112,100,11, 100,100,11, 100,75,11, 87,75,11
      ;cordis next layer
      db 63,87,20, 87,87,20, 106,106,20, 125,87,20, 150,87,20, 162,100,20, 160,125,20
      db 150,150,20, 106,175,20, 62,150,20, 50,125,20, 50,100,20, 87,125,30,125,125,30
      ;crux nx l
      db 87, 67,19,  100,67,19,  100,56,19,    112,56,19,    112,67,19,   125,67,19
      db 125,75,19,  112,75,19,  112,100,19,   100,100,19,   100,75,19,   87,75,19
    if 0
      fire_points:
      dw 66 ,79,-1
      dw 67 ,79,-5
      dw 71 ,79,-7
      dw 76 ,79,-7
      dw 79 ,79,-5
      dw 80 ,79,-1
      dw 77 ,79,1
      dw 73 ,80,2
      dw 68 ,80,1
      dw 40 ,22,6
      dw 40 ,22,-9
      dw 57 ,21,-21
      dw 82 ,21,-22
      dw 102,22,-1
      dw 110,22,3
      dw 102,23,18
      dw 80 ,23,24
      dw 56 ,23,19
      fire_points_count =  ($-fire_points)/6
    end if
      hrt_points_count  =  ($-hrt_points)/3
      hrt_triangles:
      db 1,0,12,  2,1,12, 9,8,12, 10,9,12, 11,10,12, 0,11,12, 12,13,2
      db 13,12,8, 3,2,13, 4,3,13, 5,4,13,  6,5,13,   7,6,13,  8,7,13
      ;crux
      db 22,21,23, 24,23,21, 25,24,14, 14,24,15, 24,18,15
      db 18,24,21, 21,20,18, 19,18,20, 16,15,18, 17,16,18
      ;cordis next layer
      db 26,27,38, 27,28,38, 34,35,38, 35,36,38, 36,37,38, 37,26,38, 38,39,34
      db 28,29,39, 29,30,39, 30,31,39, 31,32,39, 32,33,39, 33,34,39, 39,38,28
      ; crux next layer
      db 47,48,49, 49,50,47, 50,51,40, 50,40,41, 50,41,44
      db 41,42,44, 42,43,44, 44,47,50, 46,47,44, 44,45,46
      ;border cordis
      db 0,1,26,  1,27,26,  1,2,27,   28,27,2,  2,3,28,  29,28,3, 3,4,29, 30,29,4, 4,5,30
      db 31,30,5, 5,6,31,   32,31,6,  6,7,32,   33,32,7, 7,8,33,  34,33,8, 8,9,34, 35,34,9
      db 9,10,35, 36,35,10, 10,11,36, 37,36,11, 11,0,37, 26,37,0
      ;border crux
      db 14,15,40, 41,40,15, 15,16,41, 42,41,16, 16,17,42, 43,42,17, 17,18,43
      db 44,43,18, 18,19,44, 45,44,19, 19,20,45, 46,45,20, 20,21,46, 47,46,21
      db 21,22,47, 48,47,22, 23,24,49, 50,49,24, 24,25,50, 51,50,25, 25,14,51
      db 14,40,51
      fireFacelist:
    if 0
      db  0+52,  1 +52, 9 +52
      db 10+52,  9 +52, 1 +52
      db  1+52,  2 +52, 10+52
      db 11+52,  10+52, 2 +52
      db  2+52,  3 +52, 11+52
      db 12+52,  11+52, 3 +52
      db  3+52,  4 +52, 12+52
      db 13+52,  12+52, 4 +52
      db  4+52,  5 +52, 13+52
      db 14+52,  13+52, 5 +52
      db  5+52,  6 +52, 14+52
      db 15+52,  14+52, 6 +52
      db  6+52,  7 +52, 15+52
      db 16+52,  15+52, 7 +52
      db  7+52,  8 +52, 16+52
      db 17+52,  16+52, 8 +52
      db  8+52,  9 +52, 17+52
      db  0+52,  9 +52, 8 +52
   end if
      hrt_triangles_count = (($-hrt_triangles)/3)
      ;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      ;tetrahedron
    tetra_points_r:
      dd -1.0, -1.0, 1.0
      dd  1.0, -1.0, 1.0
      dd  0.0,  1.0, 0.0
      dd  0.0, -1.0,-1.0
    tetra_points_count = 4
    tetra_triangles:
      db 0,1,2, 2,3,0, 2,1,3,  1,0,3
    tetra_triangles_count = 4

  if 0
    cube_pts:
    db  1,  1, -1
    db  1,  -1, -1
    db  -1, -1, -1
    db  -1,  1, -1

    db  1, 1, 1
    db  1, -1, 1
    db  -1, -1, 1
    db  -1, 1, 1

    cube_tris:
    db 2, 0, 1, 0, 2, 3   ; back
    db 4, 6, 5, 6, 4, 7   ; front
    db 0, 4, 1, 5, 4, 1   ; up
    db 3, 2, 7, 7, 6, 2   ; bottom

    db 0, 4, 3, 4, 3, 7   ; right side
    db 0, 1, 2, 0, 2, 3   ; back
  end if

    font_table:
    file 'font8x16.bmp'
    font_tab2:
    file 'font8X9.bmp'
       ; horizontal line info for first stage
       ; triangles render routines
    render_opts:
                   ; renedring options each render mode - 1 byte
                   ; sec byte - threads count

   db 01000000b    ; point light wit shd
   db 01000001b    ; flat float  ;  0 bit - col      xmm0/xmm2
   db 01101001b    ; grd
   db 00000110b    ; env         ;  2 bit - tex/bump  - xmm6
   db 00000110b    ; bump        ;  7 bit - normals -  xmm1,2,3
   db 00000100b    ; tex
   db 01101101b    ; grd tex     ;  5 bit - x max/ min - xmm5
   db 00000110b    ; two tex     ;  3 bit - grd col withz value
   db 00000110b    ; bump tex         in xmm0, xmm2
   db 10000000b    ; grd line    ;  4 bit - stencil
   db 01000001b    ; flat f   10
   db 10000000b    ; tex lin env
   db 10000001b    ; tex l tex    ; bit 1 set = env 2 thread              \
   db 10000001b    ; plain line   ; bit 6 set = col grd/flat two thread   |> Now this is used
   db 10000001b    ; nodes        ; bit 7 set = one thread                /

   db 00000000b    ; bi fil
   db 00000000b    ; glass
   db 00000000b    ; gl tex
   db 00000000b    ; weigh tex
   db 00000000b    ; peel
   db 00000000b    ; fur
   ; all R Phong - see peel: proc in win3ds.asm file

menu_jmp_table_ptr:
   dw 0
   dw 0
   dw buttons.nx3             - buttons
   dw buttons.nx4             - buttons
   dw buttons.nx5             - buttons
   dw buttons.nx6             - buttons
   dw buttons.nx7             - buttons
   dw buttons.nx8             - buttons
   dw buttons.nx9             - buttons
   dw 0  ;buttons.nx10        - buttons
   dw buttons.nx11            - buttons
   dw 0  ;buttons.nx12        - buttons
   dw buttons.nx13            - buttons
   dw buttons.nx14            - buttons
   dw buttons.nx15            - buttons
   dw buttons.nx16            - buttons
   dw buttons.nx17            - buttons ; edit
   dw 0 ;buttons.nx18         - buttons
   dw buttons.nx19            - buttons
   dw buttons.nx20            - buttons
   dw buttons.nx21            - buttons
   dw buttons.nx22            - buttons
   dw 0  ;buttons.nx23        - buttons
   dw 0  ;buttons.nx24        - buttons
   dw 0  ;buttons.nx25        - buttons
   dw buttons.nx26            - buttons
   dw buttons.nx27            - buttons
   dw buttons.nx28            - buttons
   dw 0  ;buttons.nx29        - buttons
   dw buttons.nx30            - buttons
   dw buttons.nx31            - buttons
   dw buttons.nx32            - buttons
   dw 0  ;buttons.nx33        - buttons
   dw 0  ;buttons.nx34        - buttons
   dw buttons.nx35            - buttons
   dw buttons.nx36            - buttons
   dw 0  ;buttons.nx37        - buttons
   dw buttons.nx38            - buttons
   dw buttons.nx39            - buttons
   dw buttons.nx50            - buttons
   dw buttons.nx41            - buttons
   dw buttons.nx42            - buttons
   dw buttons.nx43            - buttons
   dw buttons.nx44            - buttons
   dw buttons.nx45            - buttons
   dw buttons.nx46            - buttons
   dw buttons.nx47            - buttons
   dw buttons.nx48            - buttons
   dw 0 ;buttons.nx49         - buttons
   dw buttons.nx50            - buttons
   dw buttons.nx51            - buttons
   dw buttons.nx52            - buttons
   dw buttons.nx53            - buttons
   dw buttons.nx54            - buttons
   dw buttons.nx55            - buttons
   dw buttons.nx56            - buttons
   dw buttons.nx57            - buttons
   dw 0 ;buttons.nx58         - buttons
   dw 0 ;buttons.nx59
   dw buttons.nx57            - buttons
   dw buttons.nx61            - buttons
   dw buttons.nx62            - buttons
   dw 0
   dw buttons.nx64            - buttons
   dw 0 ;buttons.nx65         - buttons
   dw buttons.nx66            - buttons
   dw buttons.nx67            - buttons
menu_button_number  dw 0
zero_flags_list:
       ; 'edit' flags described situations that collided one to another
       ; Data structure used in zero_flags: proc. See win3dsXX.asm file
       dw edit_flag     - menu_flags  ; nx17
       EDIT_F = 00000001b
       dw bezier_flag   - menu_flags  ; nx21
       BEZI_F = 00000010b
       dw derive_flag   - menu_flags  ; nx23
       DERI_F = 00000100b
       dw lpipe_flag    - menu_flags  ; nx27
       LPIP_F = 00001000b
       dw ffd_flag      - menu_flags  ; nx60
       FFD_F  = 00010000b
       dw show_ch_flag  - menu_flags  ; nx50
       SHCH_F = 00100000b
       dw chunks_o_flag - menu_flags  ; nx40
       CHUN_F = 01000000b
       EDIT_COLL_F_CNT = ($ - zero_flags_list) / 2
menu_data:
               db 0                ; mark if button chosen
               dw 2                ; x1
               dw 2                ; y1
               dw 85               ; x2
               dw 20               ; y2
               db 'rotary    ',0   ; label
    .max_flag  db 4                ; max flag  + 1 , if = 255, no flag
;   rotary_fl   db 0                ; flag
    .caption   dw axl_f - flags_caption           ; offset to flags description
    .butt_no   dw 1                ; button number
    .key1      db VK_F12           ; key 1
    .key2      db 0                ; key 2 if '0' - none

 .op   =  ($ - menu_data)

               db 0
               dw 2                ; x1
               dw 22               ; y1
               dw 85               ; x2
               dw 40
               db 'mot. blur ',0
               db 2
;   blur_fl     db 1
               dw on_of_f - flags_caption
               dw 2
               db VK_F1
               db 0

               db 0
               dw 2                ; x1
               dw 42               ; y1
               dw 85               ; x2
               dw 60
               db 'zoom in   ',0
               db 2
            ;   db 0
               dw -1               ; if 0xffff - no flag desc
               dw 3
               db VK_F3
               db VK_ADD

               db 0
               dw 2                ; x1
               dw 62               ; y1
               dw 85               ; x2
               dw 80
               db 'zoom out  ',0
               db 2
           ;    db 0
               dw -1
               dw 4
               db VK_F4
               db VK_SUBTRACT


               db 0
               dw 2                ; x1
               dw 82               ; y1
               dw 85               ; x2
               dw 100
               db 'tex. mapp.',0
               db 4
;    map_fl     db 0
               dw tex_map_f  - flags_caption
               dw 5
               db VK_F5
               db 0

               db 0
               dw 2
               dw 102
               dw 85
               dw 120
               db 'ran. light',0
               db 2
;       rd_f  l db 0
               dw -1
               dw 6
               db VK_TAB
               db 0

               db 0
               dw 2                ; x1
               dw 122              ; y1
               dw 85               ; x2
               dw 140
               db 'dr. model ',0
     max_draw  db 22 ; max val changed if non sse4
;     draw_fl   db 0 ;15  ; - only nodes (vertices) dbg
               dw -1
               dw 7
               db VK_SPACE
               db 0

               db 0
               dw 2                ; x1
               dw 142              ; y1
               dw 85               ; x2
               dw 160
               db 'bumps     ',0
               db 2
;       bump_fl db 0
               dw bumps_f - flags_caption
               dw 8
               db VK_F6
               db 0

               db 0
               dw 2                ; x1
               dw 162              ; y1
               dw 85               ; x2
               dw 180
               db 'texture   ',0
               db 4
 ;    tex_fl  db 0
               dw tex_f - flags_caption
               dw 9
               db VK_F7
               db 0

               db 0
               dw 2                ; x1
               dw 182              ; y1
               dw 85               ; x2
               dw 200
               db 'save obj. ',0
               db 8
 ;   save_fl  db 0
               dw sav_f - flags_caption
               dw 10
               db VK_F8
               db 0

               db 0
               dw 2                ; x1
               dw 202              ; y1
               dw 85               ; x2
               dw 220
               db 'process   ',0   ; label
               db 2              ; max flag  + 1 , if = 255, no flag
;  process_fl db 0                ; flag
               dw -1               ; offset to flags description
               dw 11               ; button number
               db 0
               db 0

               db 0
               dw 2                ; x1
               dw 222              ; y1
               dw 85               ; x2
               dw 240
               db 'culling   ',0
               db 2
;  culling_fl db 1
               dw on_of_f  - flags_caption
               dw 12
               db VK_F9
               db 0


               db 0
               dw 130             ; x1
               dw 2               ; y1
               dw 212             ; x2
               dw 20
               db 'do displ. ',0  ; displacement
               db 2
 ;              db 0
               dw -1
               dw 13
               db 0x44             ; D
               db 0

               db 0
               dw 130              ; x1
               dw 22               ; y1
               dw 212              ; x2
               dw 40
               db 'do triang.',0
               db 2
  ;             db 0
               dw -1
               dw 14
               db 0x54             ; T
               db 0

               db 0
               dw 130              ; x1
               dw 42               ; y1
               dw 212              ; x2
               dw 60               ; y2
               db 'cur object',0
               db 3  ; 6
   ;   hrt_fl db 0
               dw cur_obj_f  - flags_caption
               dw 15
               db VK_F2
               db 0


               db 0                ; mark if button chosen
               dw 130              ; x1
               dw 62               ; y1
               dw 212              ; x2
               dw 80               ; y2
               db 'rand. shd.',0   ; label
               db 2              ; max flag  + 1 , if = 255, no flag
  ;  xchg_fl  db 0                ; flag
               dw -1               ; offset to flags description
               dw 16               ; button number
               db 0x55             ; key 1
               db 0                ; key 2 if '0' - none

               db 0                ; mark if button chosen
               dw 130              ; x1
               dw 82               ; y1
               dw 212              ; x2
               dw 100              ; y2
               db 'edit mesh.',0   ; label
               db 4                ; max flag  + 1 , if = 255, no flag
  ;  edit_fl  db 0                ; flag
               dw edit_f - flags_caption      ; offset to flags description
               dw 17               ; button number
               db 0x56             ; key 1    'V'
               db 0                ; key 2 if '0' - none

               db 0
               dw 130              ; x1
               dw 102              ; y1
               dw 212              ; x2
               dw 120
               db 'set t.area',0
               db 2
; set_tri_area_fl  db 1
               dw on_of_f - flags_caption     ; if 0xffff  - no flag desc
               dw 18
               db 0x57             ; W
               db 0

               db 0           ; set displacement transparent color
               dw 130         ; x1
               dw 122         ; y1
               dw 212         ; x2
               dw 140
               db 'set t. col',0
               db 2
; disp_col_fl db 0
               dw displac_f - flags_caption
               dw 19
               db 0x43
               db 0

               db 0                ; mark if button chosen
               dw 130              ; x1
               dw 142              ; y1
               dw 212              ; x2
               dw 160              ; y2
               db 'dsp factor',0   ; label
               db 12               ; max flag  + 1 , if = 255, no flag
; disp_fac_fl db 0                ; flag
               dw approx_toler_f - flags_caption  ; offset to flags description
               dw 20               ; button number
               db 0x46             ; key 1    'F'
               db 0                ; key 2 if '0' - none

               db 0                ; mark if button chosen
               dw 130              ; x1
               dw 162              ; y1
               dw 212              ; x2
               dw 180              ; y2
               db 'bezier sr.',0   ; label
               db 6                ; max flag  + 1 , if = 255, no flag
 ; bezier_fl  db 0                ; flag
               dw bezier_f - flags_caption  ; offset to flags description
               dw 21               ; button number
               db 0x42             ; 'B'
               db 0

               db 0                ; mark if button chosen
               dw 130              ; x1
               dw 182              ; y1
               dw 212              ; x2
               dw 200              ; y2
               db 'set ap tol',0   ; label
               db 12               ; max flag  + 1 , if = 255, no flag
;tolerancy_fl db 1                ; flag
               dw approx_toler_f - flags_caption  ; offset to flags description
               dw 22               ; button number
               db 0x41             ;   'A'
               db 0

               db 0                ; mark if button chosen
               dw 130              ; x1
               dw 202              ; y1
               dw 212              ; x2
               dw 220              ; y2
               db 'b.der.edit',0   ; label
               db 2                ; max flag  + 1 , if = 255, no flag
;derive_fl    db 0                ; flag
               dw of_on_f - flags_caption   ; offset to flags description
               dw 23               ; button number
               db 0x45             ;   'e'
               db 0

               db 0                ; mark if button chosen
               dw 130              ; x1
               dw 222              ; y1
               dw 212              ; x2
               dw 240              ; y2
               db 't&d wh|pos',0   ; label
               db 2                ; max flag  + 1 , if = 255, no flag
;td_wp_fl     db 0                ; triangulation & displacement flag
                                   ; if set on 'posi' - only positive
                                   ; z cooficient vertices are affected,
                                   ; if set on 'whol' all vertices are
                                   ; in triangulation and displacement
                                   ; process affected
               dw t_and_d_f - flags_caption       ; offset to flags description
               dw 24               ; button number
               db 0                ;
               db 0

               db 0                ; mark if button chosen
               dw 258              ; x1
               dw 2                ; y1
               dw 340              ; x2
               dw 20               ; y2
               db 'speed     ',0   ; label
               db 2                ; max flag  + 1 , if = 255, no flag
;speed_fl     db 0                ; flag
               dw speed_f - flags_caption   ; offset to flags description
               dw 25               ; button number
               db 0x53             ;   'S'
               db 0

               db 0                ; mark if button chosen
               dw 258              ; x1
               dw 22               ; y1
               dw 340              ; x2
               dw 40               ; y2
               db 'Rm unu ver',0   ; label
               db 2                ; max flag  + 1 , if = 255, no flag
 ;              db 0                ; flag
               dw -1               ; offset to flags description
               dw 26               ; button number
               db 19
               db 0

               db 0                ; mark if button chosen
               dw 258              ; x1
               dw 42               ; y1
               dw 340              ; x2
               dw 60               ; y2
               db 'Lpipe/SplW',0   ; label
               db 4                ; max flag  + 1 , if = 255, no flag
 ; lpipe_fl   db 0                ; flag
               dw lpipe_f - flags_caption         ; offset to flags description
               dw 27               ; button number
               db 0x50             ;   'P'
               db 0

               db 0                ; mark if button chosen
               dw 258              ; x1
               dw 62               ; y1
               dw 340              ; x2
               dw 80               ; y2
               db 'Crv seg Cn',0   ; label
               db 4                ; max flag  + 1 , if = 255, no flag
 ; lpsegs_fl  db 2                ; flag
               dw lp_segs_f - flags_caption ; offset to flags description
               dw 28               ; button number
               db 0x49             ;   ''
               db 0

               db 0                ; mark if button chosen
               dw 258              ; x1
               dw 82               ; y1
               dw 340              ; x2
               dw 100              ; y2
               db 'Curve type',0   ; label
               db 4                ; max flag  + 1 , if = 255, no flag
 ; lpcurve_tp_fl   db 0                ; flag
               dw lp_cv_type_f - flags_caption    ; offset to flags description
               dw 29               ; button number
               db 0x49             ;   ''
               db 0

               db 0                ; mark if button chosen
               dw 258              ; x1
               dw 102              ; y1
               dw 340              ; x2
               dw 120              ; y2
               db 'To pieces ',0   ; label
               db 2                ; max flag  + 1 , if = 255, no flag
 ; to_piec_fl db 0                ; flag
               dw of_on_f - flags_caption
               dw 30               ; button number
               db 0x49             ;   ''
               db 0

               db 0                ; mark if button chosen
               dw 258              ; x1
               dw 122              ; y1
               dw 340              ; x2
               dw 140              ; y2
               db 'NextM edit',0   ; label   ; next mesh edit
               db 5               ; max flag  + 1 , if = 255, no flag
; NextMed_fl  db 0                ; flag
               dw nx_ed_f - flags_caption   ; offset to flags description
               dw 31               ; button number
               db 0x16             ;   ''
               db 72

               db 0                ; mark if button chosen
               dw 258              ; x1
               dw 142              ; y1
               dw 340              ; x2
               dw 160              ; y2
               db 'Rm red ver',0   ; label   ; next mesh edit
               db 2              ; max flag  + 1 , if = 255, no flag
 ;              db 0                ; flag
               dw -1               ; offset to flags description
               dw 32               ; button number
               db 0x51             ;   ''
               db 0

               db 0                ; mark if button chosen
               dw 258              ; x1
               dw 162              ; y1
               dw 340              ; x2
               dw 180              ; y2
               db 'Draw norm.',0   ; label
               db 3                ; max flag  + 1 , if = 255, no flag
;  normals_fl db 0                ; flag
               dw normals_f - flags_caption  ; offset to flags description
               dw 33               ; button number
               db 0x4f             ; 'o'
               db 0

               db 0                ; mark if button chosen
               dw 258              ; x1
               dw 182              ; y1
               dw 340              ; x2
               dw 200              ; y2
               db 'Z&chu care',0   ; label
               db 3                ; max flag  + 1 , if = 255, no flag
 ;  Z_care_fl db 1                ; flag
               dw of_on_f - flags_caption    ; offset to flags description
               dw 34               ; button number
               db 0x52             ;  'r'
               db 0

               db 0                ; mark if button chosen
               dw 258              ; x1
               dw 202              ; y1
               dw 340              ; x2
               dw 220              ; y2
               db 'Rm ins fac',0   ; label
               db 2              ; max flag  + 1 , if = 255, no flag
  ;             db 0                ; flag
               dw -1               ; offset to flags description
               dw 35               ; button number
               db 0x54
               db 0

                    db 0                ; mark if button chosen
                    dw 258              ; x1
                    dw 222              ; y1
                    dw 340              ; x2
                    dw 240              ; y2
                    db 'Ma Coll Ed',0   ; label
                    db 2                ; max flag  + 1 , if = 255, no flag
;  mark_coll_ed_fl db 0                ; flag
                    dw of_on_f  - flags_caption ;  offset to flags description
                    dw 36               ; button number
                    db 0x1e
                    db 0

                    db 0                ; mark if button chosen
                    dw 2                ; x1
                    dw 242              ; y1
                    dw 85               ; x2
                    dw 260              ; y2
                    db 'Small tex ',0   ; label
                    db 2                ; max flag  + 1 , if = 255, no flag
;   s_tex_fl       db 0                ; flag
                    dw of_on_f - flags_caption    ; offset to flags description
                    dw 37               ; button number
                    db 0x1e
                    db 0

                    db 0                ; mark if button chosen
                    dw 2                ; x1
                    dw 262              ; y1
                    dw 85               ; x2
                    dw 280              ; y2
                    db 'Sm ins edg',0   ; label
                    db 2                ; max flag  + 1 , if = 255, no flag
                ;    db 0                ; flag
                    dw -1               ; offset to flags description
                    dw 38               ; button number
                    db 0x1e
                    db 0

                    db 0                ; mark if button chosen
                    dw 2                ; x1
                    dw 282              ; y1
                    dw 85               ; x2
                    dw 300              ; y2
                    db 'Clip faces',0   ; label
                    db 2                ; max flag  + 1 , if = 255, no flag
                ;    db 0                ; flag
                    dw -1               ; offset to flags description
                    dw 39               ; button number
                    db 0x1e
                    db 0

                    db 0                ; mark if button chosen
                    dw 2                ; x1
                    dw 302              ; y1
                    dw 85               ; x2
                    dw 320              ; y2
                    db 'Ch|T opers',0   ; label
                    db 8                ; max flag  + 1 , if = 255, no flag
  ;  chunks_o_fl   db 0                ; flag
                    dw chu_oper_f - flags_caption ; offset to flags description
                    dw 40               ; button number
                    db 0x1e
                    db 0

                    db 0                ; mark if button chosen
                    dw 2                ; x1
                    dw 322              ; y1
                    dw 85               ; x2
                    dw 340              ; y2
                    db 'Crop front',0   ; label
                    db 2              ; max flag  + 1 , if = 255, no flag
                ;    db 0                ; flag
                    dw -1               ; offset to flags description
                    dw 41               ; button number
                    db 0x1e
                    db 0

                    db 0                ; mark if button chosen
                    dw 2                ; x1
                    dw 342              ; y1
                    dw 85               ; x2
                    dw 360              ; y2
                    db 'St Shadows',0   ; label
                    db 2                ; max flag  + 1 , if = 255, no flag
 ;   stencil_s_fl  db 0                ; flag
                    dw of_on_f  - flags_caption  ; offset to flags description
                    dw 42               ; button number
                    db 0x1e
                    db 0

                    db 0                ; mark if button chosen
                    dw 2                ; x1
                    dw 362              ; y1
                    dw 85               ; x2
                    dw 380              ; y2
                    db 'Sm ins ed2',0   ; label
                    db 2 ;            ; max flag  + 1 , if = 255, no flag
               ;     db 0                ; flag
                    dw -1 ;             ; offset to flags description
                    dw 43               ; button number
                    db 0x1e
                    db 0

                    db 0                ; mark if button chosen
                    dw 2                ; x1
                    dw 382              ; y1
                    dw 85               ; x2
                    dw 400              ; y2
                    db 'Tes TIV IE',0   ; label
                    db 2              ; max flag  + 1 , if = 255, no flag
              ;      db 0                ; flag
                    dw -1               ; offset to flags description
                    dw 44               ; button number
                    db 0x1e
                    db 0

                    db 0                ; mark if button chosen
                    dw 2                ; x1
                    dw 402              ; y1
                    dw 85               ; x2
                    dw 420              ; y2
                    db 'Mark in vr',0   ; label
                    db 2                ; max flag  + 1 , if = 255, no flag
;    inner_vert_fl db 0                ; flag
                    dw of_on_f - flags_caption
                    dw 45               ; button number
                    db 0x1e
                    db 0

                    db 0                ; mark if button chosen
                    dw 2                ; x1
                    dw 422              ; y1
                    dw 85               ; x2
                    dw 440              ; y2
                    db 'Rm TIV NIE',0   ; label
                    db 2              ; max flag  + 1 , if = 255, no flag
                ;    db 0                ; flag
                    dw -1               ; offset to flags description
                    dw 46               ; button number
                    db 0x1e
                    db 0

                    db 0                ; mark if button chosen
                    dw 130              ; x1
                    dw 242              ; y1
                    dw 212              ; x2
                    dw 260              ; y2
                    db 'Rm non tri',0   ; label
                    db 2              ; max flag  + 1 , if = 255, no flag
             ;       db 0                ; flag
                    dw -1               ; offset to flags description
                    dw 47               ; button number
                    db 0x1e
                    db 0

                    db 0                ; mark if button chosen
                    dw 130              ; x1
                    dw 262              ; y1
                    dw 212              ; x2
                    dw 280              ; y2
                    db 'Rm cracks ',0   ; label
                    db 2              ; max flag  + 1 , if = 255, no flag
            ;        db 0                ; flag
                    dw -1               ; offset to flags description
                    dw 48               ; button number
                    db 0x1e
                    db 0


                    db 0                ; mark if button chosen
                    dw 130              ; x1
                    dw 282              ; y1
                    dw 212              ; x2
                    dw 300              ; y2
                    db 'Tes Wh/Tar',0   ; label
                    db 2                ; max flag  + 1 , if = 255, no flag
   ;   tes_mod_fl  db 1                ; flag
                    dw tes_f - flags_caption
                    dw 49               ; button number
                    db 0x1e
                    db 0

                    db 0                ; mark if button chosen
                    dw 130              ; x1
                    dw 302              ; y1
                    dw 212              ; x2
                    dw 320              ; y2
                    db 'Show chunk',0   ; label
                    db 2                ; max flag  + 1 , if = 255, no flag
 ;    show_ch_fl     db 0                ; flag
                    dw of_on_f - flags_caption   ; offset to flags description
                    dw 50               ; button number
                    db 0x1e
                    db 0

                    db 0                ; mark if button chosen
                    dw 130              ; x1
                    dw 322              ; y1
                    dw 212              ; x2
                    dw 340              ; y2
                    db 'tex +     ',0   ; label
                    db 2              ; max flag  + 1 , if = 255, no flag
               ;     db 0                ; flag
                    dw -1               ; offset to flags description
                    dw 51               ; button number
                    db 0x1e
                    db 0

                    db 0                ; mark if button chosen
                    dw 130              ; x1
                    dw 342              ; y1
                    dw 212              ; x2
                    dw 360              ; y2
                    db 'tex -     ',0   ; label
                    db 2              ; max flag  + 1 , if = 255, no flag
              ;      db 0                ; flag
                    dw -1               ; offset to flags description
                    dw 52               ; button number
                    db 0x1e
                    db 0

                    db 0                ; mark if button chosen
                    dw 130              ; x1
                    dw 362              ; y1
                    dw 212              ; x2
                    dw 380              ; y2
                    db 'fix norm V',0   ; label
                    db 2              ; max flag  + 1 , if = 255, no flag
            ;        db 0                ; flag
                    dw -1               ; offset to flags description
                    dw 53               ; button number
                    db 0x1e
                    db 0

                    db 0                ; mark if button chosen
                    dw 130              ; x1
                    dw 382              ; y1
                    dw 212              ; x2
                    dw 400              ; y2
                    db 'make serie',0   ; label
                    db 2              ; max flag  + 1 , if = 255, no flag
           ;         db 0                ; flag
                    dw -1               ; offset to flags description
                    dw 54               ; button number
                    db 0x1e
                    db 0

                    db 0                ; mark if button chosen
                    dw 130              ; x1
                    dw 402              ; y1
                    dw 212              ; x2
                    dw 420              ; y2
                    db 'sort chunk',0   ; label
                    db 2              ; max flag  + 1 , if = 255, no flag
             ;       db 0                ; flag
                    dw -1               ; offset to flags description
                    dw 55               ; button number
                    db 0
                    db 0

                    db 0                ; mark if button chosen
                    dw 130              ; x1
                    dw 422              ; y1
                    dw 212              ; x2
                    dw 440              ; y2
                    db 'Submit obj',0   ; label
                    db 2                ; max flag  + 1 , if = 255, no flag
  ;     submit_fl  db 0                ; flag
                    dw blank_f - flags_caption    ; offset to flags description
                    dw 56               ; button number
                    db 0
                    db 0

                    db 0                ; mark if button chosen
                    dw 340 - 82         ; x1
                    dw 242              ; y1
                    dw 340              ; x2
                    dw 260              ; y2
                    db 'Zero Next ',0   ; label
                    db 2              ; max flag  + 1 , if = 255, no flag
  ;     zero_Nx_fl db 0                ; flag
                    dw -1               ; offset to flags description
                    dw 57               ; button number
                    db 0
                    db 0

                    db 0                ; mark if button chosen
                    dw 340 - 82         ; x1
                    dw 262              ; y1
                    dw 340              ; x2
                    dw 280              ; y2
                    db 'run / stop',0
                    db 2
  ;     ccounter_inc_fl db 1
                    dw run_st_f - flags_caption
                    dw 58
                    db VK_F11
                    db 0

                    db 0                ; mark if button chosen
                    dw 340 - 82         ; x1
                    dw 282              ; y1
                    dw 340              ; x2
                    dw 300              ; y2
                    db 'Shadow    ',0   ; label
                    db 2                ; max flag  + 1 , if = 255, no flag
;     shadow_fl    db 0                ; flag
                    dw of_on_f - flags_caption    ; offset to flags description
                    dw 59               ; button number
                    db 0
                    db 0

                    db 0                ; mark if button chosen
                    dw 340 - 82         ; x1
                    dw 302              ; y1
                    dw 340              ; x2
                    dw 320              ; y2
                    db 'FFD       ',0   ; label
     maxffd         db 5                ; max flag  + 1 , if = 255, no flag
  ;   ffd_fl       db 0                ; flag
                    dw ffd_f  - flags_caption     ; offset to flags description
                    dw 60               ; button number
                    db 0 ;0x4e
                    db 0

                    db 0                ; mark if button chosen
                    dw 340 - 82         ; x1
                    dw 322              ; y1
                    dw 340              ; x2
                    dw 340              ; y2
                    db 'R Ph bumps',0   ; label
     max_rpbump     db 4                ; max flag  + 1 , if = 255, no flag
  ;   rph_bump_fl  db 0                ; flag
                    dw rphb_f  - flags_caption    ; offset to flags description
                    dw 61               ; button number
                    db 0 ;0x4e
                    db 0

                    db 0                ; mark if button chosen
                    dw 340 - 82         ; x1
                    dw 342              ; y1
                    dw 340              ; x2
                    dw 360              ; y2
                    db 'DoDefNxNor',0   ; label
                    db 2              ; max flag  + 1 , if = 255, no flag
                ;    db 0                ; flag
                    dw -1               ; offset to flags description
                    dw 62               ; button number
                    db 0 ;0x4e
                    db 0

                    db 0                ; mark if button chosen
                    dw 340 - 82         ; x1
                    dw 362              ; y1
                    dw 340              ; x2
                    dw 380              ; y2
                    db 'Dr.ValencE',0   ; label
                    db 2                ; max flag  + 1 , if = 255, no flag
;    valencEd_fl   db 0                ; flag
                    dw of_on_f - flags_caption    ; offset to flags description
                    dw 63               ; button number
                    db 0 ;0x4e
                    db 0

                    db 0                ; mark if button chosen
                    dw 340 - 82         ; x1
                    dw 382              ; y1
                    dw 340              ; x2
                    dw 400              ; y2
                    db 'From tex  ',0   ; label
                    db 1                ; max flag  + 1 , if = 255, no flag
 ;    from_tex_fl   db 0                ; flag
                    dw -1               ; offset to flags description
                    dw 64               ; button number
                    db 0
                    db 0

                    db 0                ; mark if button chosen
                    dw 340 - 82         ; x1
                    dw 402              ; y1
                    dw 340              ; x2
                    dw 420              ; y2
                    db 'Opt object',0   ; label
                    db 4                ; max flag  + 1 , if = 255, no flag
  ;  opt_mesh_fl   db 0                ; flag
                    dw opt_m_f - flags_caption    ; offset to flags description
                    dw 65               ; button number
                    db 0
                    db 0

                    db 0                ; mark if button chosen
                    dw 340 - 82         ; x1
                    dw 422              ; y1
                    dw 340              ; x2
                    dw 440              ; y2
                    db 'process op',0   ; label
                    db 1                ; max flag  + 1 , if = 255, no flag    + 20
         ;           db 0                ; flag
                    dw -1               ; offset to flags description          + 22
                    dw 66               ; button number                        + 24
                    db 0
                    db 0
MENU_SIZE = $ - menu_data
                    dw -1  ; <- end flag

menu_data2:
             ;  db 0                ; mark if button chosen
             ;  dw 2                ; x1
             ;  dw 2                ; y1
             ;  dw 85               ; x2
             ;  dw 20               ; y2
               db 'morph     ',0   ; label
               db 2                ; max flag  + 1 , if = 255, no flag
  ;  morph_fl  db 0                ; flag
               dw of_on_f - flags_caption           ; offset to flags description
               dw 67               ; button number
               db 0                ; key 1
               db 0                ; key 2 if '0' - none
MENU_SIZE2 = $ - menu_data2
menu_flags:
          rotary_flag       db 0
          blur_flag         db 1
                            db -1
                            db -1
          map_flag          db 0
          rd_flag           db 0
          draw_flag         db 0
          bump_flag         db 0
          tex_flag          db 0
          save_flag         db 0
          process_flag      db 0
          culling_flag      db 1
                            db -1
                            db -1
          hrt_flag          db 0
          xchg_flag         db 0
          edit_flag         db 0
          set_tri_area_flag db 1
          disp_col_flag     db 0
          disp_fac_flag     db 0
          bezier_flag       db 0
          tolerancy_flag    db 1
          derive_flag       db 0
          td_wp_flag        db 0
          speed_flag        db 0
                            db -1
          lpipe_flag        db 0
          lpsegs_flag       db 2
          lpcurve_tp        db 0
          to_piec_flag      db 0
          NextMed_flag      db 0
                            db -1
          normals_flag      db 0
          Z_care_flag       db 1
                            db -1
          mark_coll_ed_flag db 0            
          s_tex_flag        db 0
                            db -1           
                            db -1           
          chunks_o_flag     db 0
                            db -1  ; crop fr
                                            
          stencil_s_flag    db 0
                            db -1           
                            db -1           
          inner_vert_flag   db 0
                            db -1           
                            db -1           
                            db -1           
          tes_mod_flag      db 1
          show_ch_flag      db 0

                            db -1
                            db -1
                            db -1
                            db -1
                            db -1
          submit_flag       db 0
          zero_Nx_flag      db 0
          ccounter_inc      db 1
          shadow_flag       db 0
          ffd_flag          db 0
          rph_bump_flag     db 0
                            db -1           
          valencEd_flag     db 0
          from_tex_flag     db 0
          opt_mesh_flag     db 0
                            db -1
          ; data2
          morph_flag        db 0

flags_caption:
opt_m_f:
   db  'hole',0
   db  'geom',0
   db  'edge',0
   db  'Rcln',0
sav_f:
   db  '3ds ',0
   db  'stl ',0
   db  'ply ',0
   db  'asc ',0
   db  'chun',0
   db  'wav ',0
   db  'mod ',0
 ;  db  'jpeg',0
chu_oper_f:
   db  'off ',0
   db  'Civr',0
   db  'Ctes',0
   db  'Cmir',0
   db  'Cdel',0
   db  'Cgeo',0
   db  'Cmrg',0
   db  'Trem',0
ffd_f:
     db 'off ',0
     db 'patc',0
     db 'vol.',0
     db 'spli',0
     db 'twis',0
blank_f:
     db '    ',0
     db '    ',0
nx_ed_f:
     db 'off ',0
     db 'Nx.o',0
     db 'chun',0
     db 'whol',0
     db 'area',0
tes_f:
     db 'tesA',0
     db 'Whol',0
normals_f:
     db 'off ',0
     db 'tri.',0
     db 'vert',0
lp_cv_type_f:
     db 'Bezr',0
     db 'Bspl',0
     db 'CatR',0
     db 'Herm',0
lp_segs_f:
     db ' 2  ',0
     db ' 4  ',0
     db ' 8  ',0
     db ' 16 ',0
lpipe_f:
     db 'off ',0
     db 'edit',0
     db 'pipe',0
     db 'wall',0

speed_f:
     db 'idle',0
     db 'full',0

t_and_d_f:
     db 'whol',0
     db 'posi',0
bezier_f:
     db 'off ',0
     db 'pot ',0
     db 'cup ',0
     db 'spoo',0
     db 'box ',0
     db 'triP',0
rphb_f:
     db 'off ',0
;lp_qual:
;lp_segs_f:
approx_toler_f:
d_factor_f:
     db '1   ',0
     db '2   ',0
     db '3   ',0
     db '4   ',0
     db '5   ',0
     db '6   ',0
     db '7   ',0
     db '8   ',0
     db '9   ',0
     db '10  ',0
     db '11  ',0
     db '12  ',0
displac_f:
     db 'whit',0
     db 'blck',0
edit_f:
     db 'off ',0
     db 'vert',0
     db 'face',0
     db 'edge',0
cur_obj_f:
     db 'file',0
     db 'hrt ',0
     db 'tetr',0
tex_map_f:
     db 'p.xy',0
     db 'p.xz',0
     db 'p.yz',0
     db 'sph.',0
axl_f:
     db 'y   ',0
     db 'z   ',0
     db 'x   ',0
     db 'cust',0
on_of_f:
     db 'on  ',0
     db 'off ',0
of_on_f:
     db 'off ',0
     db 'on  ',0
     db 'chun',0
bumps_f:
     db 'rand',0    ; random
     db 'tex ',0    ; texture
tex_f:
     db 'str.',0    ; stipes
     db 'xor ',0    ;
     db 'mand',0    ; mandelbrot
     db 'none',0    ;
run_st_f:
     db  'stop',0
     db  'run ',0
 if 0
    jpeg:
    file 'im2.bin'
    zigzag:
     db  0,   1,   5,  6,   14,  15,  27,  28
     db  2,   4,   7,  13,  16,  26,  29,  42
     db  3,   8,  12,  17,  25,  30,  41,  43
     db  9,   11, 18,  24,  31,  40,  44,  53
     db  10,  19, 23,  32,  39,  45,  52,  54
     db  20,  22, 33,  38,  46,  51,  55,  60
     db  21,  34, 37,  47,  50,  56,  59,  61
     db  35,  36, 48,  49,  57,  58,  62,  63
 ;    db 0xff
    ; quantization values
   q:
    db 16, 11, 10, 16, 24, 40, 51, 61
    db 12, 12, 14, 19, 26, 58, 60, 55
    db 14, 13, 16, 24, 40, 57, 69, 56
    db 14, 17, 22, 29, 51, 87, 80, 62
    db 18, 22, 37, 56, 68, 109, 103, 77
    db 24, 35, 55, 64, 81, 104, 113, 92
    db 49, 64, 78, 87, 103, 121, 120, 101
    db 72, 92, 95, 98, 112, 100, 103, 99
;    db 0xff
  ;  rd 1000
  end if

    Def_Derv_flag         db 0
    custom_obj_angle      dd 0
    custom_rot_start_x    dw 0, 0
    edit_particle_no      dd -1
    edit_tri_area         db 0
    displ_transparent_col dd 0x00ffffff

    min_work_x:     dw 6         ; \
    min_work_y      dw 6         ; |> dont change order
    max_work_x:     dw 4000      ; |
    max_work_y      dw 2200      ; /

    ; Bezier models taken from:
    ; https://people.sc.fsu.edu/~jburkardt/data/bezier_surface/bezier_surface.html
    bezier_nodes:
    ; Each node = 3 values, each value as 11 bit unsigned integer
    ; into floats convertion see win3ds.asm file 
    file 'bezier_nodes.bin'
    bezier_rects:
    ; Each rect = 16 values, each value is 9 bit index to node
    ; into words conv see win3ds.asm file
    file 'bezier_rects.bin'
;    tspoon_nodes:
;   include 'tspoon_nodes.txt'
;    tcup_nodes:
;   include 'tcup_nodes.txt'
;    tpot_nodes:
;   include 'tpot_nodes.txt'
;    ffd_nodes:
;   include 'ffd2_nodes.txt'
;    tspoon_rect:
;   include 'tspoon_rect.txt'
;    tcup_rect:
;   include 'tcup_rect.txt'
;    tpot_rect:
;   include 'tpot_rect.txt'
;    ffd_rect:
;   include 'ffd2_rect.txt'
  ed_bpatch:
    .derives_x_start: dw 0   ; bezier patch edition
    .derives_y_start  dw 0
    .derives_x_end:   dw 0
    .derives_y_end    dw 0
    .derive_no        dw 2   ; number
    .derive_on        db 0   ; 0 - off, 1 - on
;   ed_bpatch_mv_process       dd 0  ; mouse move process

    tex_mov_begin_x:
                      dw 0 ;  \ dont change order
    tex_mov_begin_y   dw 0 ;  /
    CoresCount        dd 0,0
  align 4
    ProcessAffinityMask dd 0
    SystemAffinityMask  dd 0
  align 4
    msg      MSG
    rect     RECT
    ofn      OPENFILENAME sizeof.OPENFILENAME,0,0,filter,0,0,0,fname,260 ;MAXSIZE
    ofntex   OPENFILENAME sizeof.OPENFILENAME,0,0,filter_tex,0,0,0,fnametex,260 ;MAXSIZE
    ofnnext  OPENFILENAME sizeof.OPENFILENAME,0,0,filter,0,0,0,fnamenext,260 ;MAXSIZE
    wc       WNDCLASS 0,WindowProc,0,0,NULL,NULL,NULL,1,NULL,_class
    long_pipe_derv_init:
       dd 1.0,0.0,0.0
    long_pipe_derv:                   ; mem for control points of
       rd 65536                       ; long pipe
    long_pipe_derv_rotated rd 65536

    lpipe_derv_size        rd 20      ; offsets
    NextBendDerv:          rb 65536
    Def_Derv_base          rb 65535
    Def_Derv               rb 65536
    Def_Derv_copy          rb 65536
    Def_Derv_verts_base    rb 65536

;------not change oder below
    NextMxadd:    dw ?     ;BXRES/2  ; next mesh variables
    NextMyadd     dw ?     ;BYRES/2  ; dont change order (all 'Next' vars)!!
    NextMzadd     dw ?     ;/BYRES/2
                  dw ?     ;0
    NextScale     dw ?     ;BYRES/2
    NextRotat:    dw ? , ? ;BYRES - 10 ,   20
    NextScaleXY:  dw ? , ? ;BYRES/2 + 12, BYRES/2


    NextBend1:    dw ?, ?  ;12   , BYRES/2
    NextBend2:    dw ?, ?  ;BYRES/2  - 12 , BYRES/2
    NextBend3:    dw ?, ?  ;BYRES/2  + 24 , BYRES/2
    NextBend4:    dw ?, ?  ;BYRES    - 24 , BYRES/2
 ;---------not change order above

    initXsize     dd ?     ; sizes at start
    initYsize     dd ?

    ffd_nodes_intial     rw 65536
    ffd_nodes_rot        rw 65536
    ffd_nodes_intial_rot rw 65536
    ffd_nodes_unpck      rb 12 * 1000 + 500 ;(max ~ 1000 unpacked  nodes)
  align 16
    ffd_nodes_unpck_inti rb 12 * 1000 + 500
  align 16
    nodes_aligned        rb 12 * 16 * 4 + 500
  align 16
    nodes_aligned_inti   rb 12 * 16 * 4 + 500
    bez_patch_count      dw ?
    bez_nodes_count      dw ?

  align 16
    thread_params:    rd 300
    thread_params_ch: rd 20
    ; params to threaded procs mem area
;  align 16
    ThreadMaskArray rd 64  ; dup 0
 ;   ABI_regs:      rd 4   ; ebx esi edi
 ;  align16
 ;   Power          rd 20  ; 1! - 20!
    to_pieces_var   dd ?
    whole_xres      dw ?
    whole_yres      dw ?
    xres_vard:
    xres_var        dw ?
    yres_var        dw ?
    File_ptr        dd ?
    File_tex_ptr    dd ?
    File_next_ptr   dd ?
    EndFile         dd ?
    EndNextFile     dd ?
    menu_buffer     rb MENU_SIZE

    edges_coll_count     dd ?
    inner_vert_number    dd ?

    edit_start_x    dw ?   ; \
    edit_start_y    dw ?   ; |
    edit_end_x      dw ?   ; |> dont change order
    edit_end_y      dw ?   ; |
    edit_start_z    dw ?   ; /

;    struct shadow_stencil
;     verts_ptr     dd ?
;     light_ptr     dd ?
;     mx_st         db 36 dup (?)
;    ends

    shd_stencil_verts_A_ptr dd ?       ; \
    stencil_shd_A_light_ptr dd ?       ;  |
    shd_stencil_mx_A        rb 36      ;  | dont change
    shd_stencil_verts_B_ptr dd ?       ;  |
    stencil_shd_B_light_ptr dd ?       ;  | order !!
    shd_stencil_mx_B        rb 36      ;  |
    shd_stencil_verts_C_ptr dd ?       ;  |
    stencil_shd_C_light_ptr dd ?       ;  |
    shd_stencil_mx_C        rb 36      ; /

  ;  front_tris_ptr                dd ?
    new_tex_ptr                   dd ?
    furs_ptr:                     dd ?

;    ptr_lab:
;      .tri_nr_ptr   = ptr_lab   + 0  ;-   triangles_normals_ptr
;      .tri_nr_r_ptr = ptr_lab   + 4  ;-   triangles_normals_rotated_ptr
;      .p_nr_ptr     = ptr_lab   + 8  ;-   points_normals_ptr
;      .pcv          = ptr_lab   + 12 ;-   points_count_var
;      .tcv          = ptr_lab   + 16 ;-   triangles_count_var


    triangles_normals_ptr         dd ?      ; \
    triangles_normals_rotated_ptr dd ?      ;  \
    points_normals_ptr            dd ?      ;  |
    points_count_var              dd ?      ;  |
    triangles_count_var           dd ?      ;  |
                                            ;  |
    points_r_ptr                  dd ?      ;  | > dont change order
    triangles_ptr                 dd ?      ;  | >
    points_rotated_ptr            dd ?      ;  |
    points_normals_rotated_ptr    dd ?      ;  |
    edges_ptr                     dd ?      ;  |
    edges_count                   dd ?      ;  |
    edge_s_d_ptr                  dd ?      ;  |
    screen_ptr                    dd ?      ;  |         ; edge single - bit is zeroed
    Zbuffer_ptr                   dd ?      ;  |
    slices_counter_ptr            dd ?      ;  |
    slices_ptrs_buff_ptr          dd ?      ;  /
    tex_points_f_ptr              dd ?      ; /

    shd_buffer_ptr                dd ?
    edit_buf_ptr                  dd ?
    edit_tri_area_ptr             dd ? ; 2 bits for each pixel
    chunks_desc_ptr               dd ?
    chunk_desc_Ex_ptr             dd ? ; every chunk 64 bytes
                                       ; first 12 - max vertex
                                       ; + 12  - min vertex
                                       ; + 24  - middle vert
                                       ; next - yet free

    tex_points_ptr                dd ?  ; bump_map  and texture coords
                                        ; each point word x, word y
  ;  shadow_vertices_ptr           dd ?
    derv_rect_ptr                 dd ?
    derv_nodes_ptr                dd ?
    long_pipe_vert_ptr            dd ?
  ;  slices_ptr                    dd ?
    voxels_depth_ptr              dd ?
 ;   tri_normals_48_ptr            dd ?    ; normal vector stored as 24 x 2 fixed points values
 ;   tri_normals_rot_48_ptr        dd ?    ; last bit as sign first bit as integer part
 ;   verts_normals_48_ptr          dd ?    ; inbetween 22 bits of fraction value
 ;   verts_normals_rot_48_ptr      dd ?    ; Stored is only Y and Y coeficient, Z should be calculated
                                           ; if its needed
  align 16
    matrix           rb 60
    matrix_scaled    rb 60
    fname            rb 260 ;MAXSIZE
    fnametex         rb 260
    fnamenext        rb 260
    BytesRead        dd ?
    hfile            dd ?
    hfiletex         dd ?
    hfilenext        dd ?

    FileSize         dd ?
    FileNextSize     dd ?
    byteswritten     dd ?

    hwnd             dd ?
    hdc              dd ?

    bmi              BITMAPINFOHEADER
    Mbmi             BITMAPINFOHEADER  ; menu scroll pipe
    Pbmi             BITMAPINFOHEADER  ; prompt
    Wbmi             BITMAPINFOHEADER  ; Whole window
    noise_buff     rb 65536 * 2 + 1024
    bezier3_nodes: rb 65535 
    bezier3_tris:  rb 65535
    tspoon_rect:    ;  \
      rw 16*16      ;   |
    tcup_rect:      ;   |
      rw 26*16      ;   |
    tpot_rect:      ;   | not xchg order
      rw 32*16      ;   |
    ffd_rect:       ;   |
      rw 6*16       ;  /
    tspoon_nodes:   ;  \
      rd 256 * 3    ;   |
    tcup_nodes:     ;   |
      rd 251 * 3    ;   |
    tpot_nodes:     ;   | not xchg order
      rd 306 * 3    ;   |
    ffd_nodes:      ;   |
      rd 56 * 3     ;  /
   ; fog_seeds      rb (128 * 128 * 64)   + 128
 ;   idct           rb 512
 ;   rd 10000
 ;   block          rb 512
 ;   rd 10000
 ;   idc_lookup     rb 512 * 64
 ;   rd 10000
    xxaddf:           rd 4
  ; fog_matrices:  rb 8 * 4 * 10
  ; agregated_fog: rb 8 * 4 + 20
  ; fog_tex:       rd 32 * 8 + 20
  align 16
  ; claud_tex      rb 256 * 256 * 4
    bump_map       rb TEX_X * TEX_Y
    envmap         rd TEX_X * TEX_Y
    color_map:     rd TEX_X * TEX_Y
    texmap         rd TEX_X * TEX_Y
    texmap_s       rd TEX_X_S * TEX_X_S
  align 16
    prompt_screen  rd PROMPTX * PROMPTY
    menu_screen    rd MXRES * MYRES
    Info_screen:
                   rd INFOX * INFOY
    Bbufferv:
                   rd BXRES*BYRES
